﻿
function weeble(url) {
    alert(url);
}

function getCalendarEvents(url) {
    $.getJSON(url, null,
     function(result) {
        assignCalendarDates(result);
     });
 }

 function assignCalendarDates(data) {
     var CalendarEvents = data;

     for (i = 0; i < CalendarEvents.length; i++) {
         var c = CalendarEvents[i];
         var date = GetDateFromJson(c.StartDateTime);
         var year = date.getFullYear();
         var dt = date.getDate();
         var month = date.getMonth();
         var event = { "EventID": c.EventID, "StartDateTime": new Date(year, month, dt), "Title": "&nbsp;mtg&nbsp;", "URL": c.URL, "Description": c.Description, "CssClass": "SelectedDateLabel" };
        events.push(event);
    }
    var options = {
        height: 200,
        width: 180,
        containerId: "#jMonthCalendar",
        headerHeight: 10,
        firstDayOfWeek: 0,
        calendarStartDate: new Date(),
        //    dragableEvents: true,
        //    activeDroppableClass: false,
        //    hoverDroppableClass: false,
        navLinks: {
            enableToday: false,
            enableNextYear: false,
            enablePrevYear: false,
            p: '&lsaquo;',
            n: '&rsaquo;',
            t: 't',
            showMore: 'Show More'
        },
        onMonthChanging: function(dateIn) { return true; },
        onMonthChanged: function(dateIn) { return true; },
        onEventLinkClick: function(event) { return true; },
        onEventBlockClick: function(event) { return true; },
        onEventBlockOver: function(event) { return true; },
        onEventBlockOut: function(event) { return true; },
        onDayLinkClick: function(date) { return true; },
        onDayCellClick: function(date) { return true; },
        onDayCellDblClick: function(dateIn) { return true; },
        onEventDropped: function(event, newDate) { return true; },
        onShowMoreClick: function(eventArray) { return true; },
        locale: {
            //        days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
            days: ["S", "M", "T", "W", "T", "F", "S", "S"],
            daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
            daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
            months: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
            //        months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
            monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
            weekMin: 'wk'
        }
    };

    $.jMonthCalendar.Initialize(options, events);
 }

 function GetDateFromJson(jsonDt) {
     var jdate = new Date(+jsonDt.replace(/\D/g, ''));
     return jdate;
 }